package com.hashTable;


import java.util.*;

public class GroupAnagrams0130_49 {
    public List<List<String>> groupAnagrams(String[] strs) {
        Map<String,List<String>> map = new HashMap<>();

        for (String str : strs) {
            char[] array = str.toCharArray();

            Arrays.sort(array);
            String s = new String(array);
            List<String> list = map.getOrDefault(s, new ArrayList<String>());
            list.add(str);
            map.put(s,list);
        }
        return new ArrayList<>(map.values());
    }
}
